<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="js/jquery-3.3.1.js"></script>
</head>
<body>
<form action="/category/findAll" method="post">
    <button>跳转</button>
</form>

<a href="${pageContext.request.contextPath}/user/save2">hello</a></br>
<a href="#" id="ajax">ajax请求</a><br>
<a href="${pageContext.request.contextPath}/user/save4?name=zhangsan&age=20">hello001</a></br>
<a href="${pageContext.request.contextPath}/user/save5?name=zhangsan&age=20">pojo</a></br>
<form action="user/save6">
    <input type="checkbox" name="subject" value="java">java<br>
    <input type="checkbox" name="subject" value="php">php<br>
    <input type="checkbox" name="subject" value="ui">ui<br>
    <button>button</button>
</form>

<form action="${pageContext.request.contextPath}/user/save7" method="post">
    第一个用户的名字:<input type="text" name="userList[0].name"><br/>
    第一个用户的年龄:<input type="text" name="userList[0].age"><br/>
    第二个用户的名字:<input type="text" name="userList[1].name"><br/>
    第二个用户的年龄:<input type="text" name="userList[1].age"><br/>
    <input type="submit" value="提交">
</form>

<a href="#" id="demo">pojo</a></br>
<a href="${pageContext.request.contextPath}/user/save9" >save9</a></br>

<form action="${pageContext.request.contextPath}/user/save10">
    <input type="text" name="date"><br>
    <input type="submit" value="提交">
</form> <br>

<a href="${pageContext.request.contextPath}/user/save11/tom/20">restful</a><br>

<a href="${pageContext.request.contextPath}/user/save12">666</a><br>
<a href="${pageContext.request.contextPath}/user/save13">888</a><br>
<script>
    $(function () {
        $("#ajax").click(function () {
            $.get("user/save3",{},function (data) {
                alert(data.name);
                alert(data.age);
            });
        });

        $("#demo").click(function () {
            let list=new Array();
            list.push({name:"zhangsan",age:20});
            list.push({name:"赵六",age:21});

            $.ajax({
                type:"post",
                url:"${pageContext.request.contextPath}/user/save8",
                data:JSON.stringify(list),
                success:function(obj){
                    alert(obj)
                },
                contentType:"application/json;charset:utf-8"
            });
        });
    })
</script>
</body>
</html>
